package com.da.javatest.leetCode;

import java.util.HashMap;

/**
 * @author chenlida
 * @date 2019/3/8 17:13
 * @description
 */
public class Code168 {

    public static void main(String[] args) {
        //HashMap<String, String> s = new HashMap<>();
        //System.out.println(s.get("aaa"));
        System.out.println(new Code168().convertToTitle(701));
    }

    public String convertToTitle(int n) {
        char[] index = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
            'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
        StringBuilder sb = new StringBuilder();
        while (n != 0) {
            if (n % 26 == 0) {
                sb.insert(0, index[25]);
                n = n / 26 - 1;
            } else {
                sb.insert(0, index[n % 26 - 1]);
                n /= 26;
            }
        }
        return sb.toString();
    }
}
